import socket

sock = socket.socket()
sock.bind(('127.0.0.1', 8800))
sock.listen(5)

while 1:
    print('server waiting...')
    conn, _ = sock.accept()
    data = conn.recv(1024)
    print('data=', data)
    # read from the html file
    '''
    with open('index.html', 'rb') as f:
        data = f.read()
    conn.send(
        b'HTTP/1.1 200 OK\r\n\r\n%s' % data)    
    '''
    with open('index.html', 'r') as f:
        data = f.read()
    conn.send(
        ('HTTP/1.1 200 OK\r\n\r\n%s' % data).encode('utf8'))
    conn.close()
